#include <iostream>
#include <iomanip>
#include "Credit.h"

using namespace std;

Credit::Credit( int naccount, double nbalance, double ncharge, double ncredit, double nlimit )
{
	setAccountNumber( naccount );
	setBalance( nbalance );
	setCharges( ncharge );
	setCredits( ncredit );
	setCreditLimit( nlimit );
}

int Credit::getAccountNumber()
{
	return AccountNumber;
}

double Credit::getBalance()
{
	return Balance;
}

double Credit::getCharges()
{
	return Charges;
}

double Credit::getCredits()
{
	return Credits;
}

double Credit::getCreditLimit()
{
	return CreditLimit;
}

void Credit::setAccountNumber( int naccount )
{
	AccountNumber = naccount > 0 ? naccount : 0;
}

void Credit::setBalance( double nbalance )
{
	Balance = nbalance > 0 ? nbalance : 0;
}

void Credit::setCharges( double ncharge )
{
	Charges = ncharge > 0 ? ncharge : 0;
}

void Credit::setCredits( double ncredit )
{
	Credits = ncredit > 0 ? ncredit : 0;
}

void Credit::setCreditLimit( double nlimit )
{
	CreditLimit = nlimit > 0 ? nlimit : 0;
}

void Credit::displayMessage()
{
	double NewBalance = getBalance() + getCharges() - getCredits();
	setBalance(NewBalance);
	cout << "New balance is " << Balance << endl;
	if (NewBalance > CreditLimit) {
		cout << "Account:       " << AccountNumber << endl;
		cout << "Credit Limit:  " << CreditLimit << endl;
		cout << "Balance:       " << Balance << endl;
		cout << "Credit Limit Exceeded" << endl;
	}
}
